﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using PresentationLayer.Views;
using EngineLayer;
using System.Threading;
using EngineLayer.Model;

namespace PresentationLayer
{
    static class Program
    {
        public static MyApplication application;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Mutex mutex = new System.Threading.Mutex(false, "MyUniqueMutexName");
            try
            {    
             /////////////////////////////////////
                Logon logon = new Logon();
                User user = new User();
                user.UserName = "sysadmin";
                user.PassWord = "sysadmin";
                logon.user = user;

                application = logon.OpenApplication(logon);
            ///////////////////////////////////
                                

                if (mutex.WaitOne(0, false))
                {
                    // Run the application
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                   // Application.Run(new LoginForm());
                    Application.Run(new ProductsCatalogsForm());
                    //Application.Run(new CashierForm());
                  //  if (User != null && User.Valid())
                    //{
                  //      Application.Run(new MainView());
                //    }
                }
                else
                {
                    MessageBox.Show("Existe una instancia de la aplicación abierta.", "Punto de Venta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                if (mutex != null)
                {
                    mutex.Close();
                    mutex = null;
                }
            }
        }
    }
}
   
 